package com.zxq.demo.admin.service.impl;

import com.zxq.demo.admin.dao.ZxqJobInfoDao;
import com.zxq.demo.admin.dao.ZxqJobLogDao;
import com.zxq.demo.admin.model.ZxqJobInfo;
import com.zxq.demo.admin.service.ZxqJobService;
import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.support.CronExpression;
import org.springframework.stereotype.Service;

import java.text.MessageFormat;
import java.util.*;

/**
 * core job action for xxl-job
 * @author zxq 2016-5-28 15:30:33
 */
@Service
public class ZxqJobServiceImpl implements ZxqJobService {
	private static Logger logger = LoggerFactory.getLogger(ZxqJobServiceImpl.class);

	@Resource
	private ZxqJobInfoDao zxqJobInfoDao;
	@Resource
	public ZxqJobLogDao zxqJobLogDao;
	
	@Override
	public Map<String, Object> pageList(int start, int length, int jobGroup, int triggerStatus, String jobDesc, String executorHandler, String author) {

		// page list
		List<ZxqJobInfo> list = zxqJobInfoDao.pageList(start, length, jobGroup, triggerStatus, jobDesc, executorHandler, author);
		int list_count = zxqJobInfoDao.pageListCount(start, length, jobGroup, triggerStatus, jobDesc, executorHandler, author);
		
		// package result
		Map<String, Object> maps = new HashMap<String, Object>();
	    maps.put("recordsTotal", list_count);		// 总记录数
	    maps.put("recordsFiltered", list_count);	// 过滤后的总记录数
	    maps.put("data", list);  					// 分页列表
		return maps;
	}

	@Override
	public List<ZxqJobInfo> jobList() {
		return zxqJobInfoDao.list(null);
	}
}
